// Drawing functions with no-clipping needed
//
// NOTE: Drawing without boundary checking can increase the performance, but
//		 it may cause diseases when drawing outside the canvas!!!
//

#ifndef __DRAW_NC_H__
#define __DRAW_NC_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "Canvas.h"
#include "Image.h"

// Params:
//  canvas      is the pointer of output/or refered canvas
//  x1,y1,x2,y2 is the starting/ending x,y coords of line (x1,y1)-(x2,y2)
//  l,t,r,b     is the left-top/right-bottom x,y coords of rectangle (l,t)-(r,b)
//  color       is the rgb value, plz use _RGB(r,g,b) macro to make it

/////////////////////////////////////////////////////////////////////////////
// Canvas drawing functions (no-clipping version)

void g_DrawPixelNC(const TCanvas *canvas, int x, int y, int color);
     
/* arbitrary line */
void g_DrawLineNC(const TCanvas *canvas, int x1, int y1, int x2, int y2, int color);

/* horizontal line (x1,y1)-(x2,y1) */
void g_DrawHLineNC(const TCanvas *canvas, int x1, int y1, int x2, int color);
void g_DrawHLineNCBlend(const TCanvas *canvas, int x1, int y1, int x2, int color, int src, int des);

/* vertical line  (x1,y1)-(x1,y2) */
void g_DrawVLineNC(const TCanvas *canvas, int x1, int y1, int y2, int color);
     
void g_DrawRectNC(const TCanvas *canvas, int l, int t, int r, int b, int color);
     
void g_DrawCircleNC(const TCanvas *canvas, int x, int y, int radius, int color);
    
void g_DrawImageNC(const TCanvas *canvas, int x, int y, const TImage *image);

/* Draw image with key(transparent) color passed */
void g_DrawImageTransNC(const TCanvas *canvas, int x, int y, const TImage *image, int keyColor);

/* Draw the RLE(OB's Transparent Run Length Encoded) images */
//void g_DrawRleNC(const TCanvas *canvas, int x, int y, const TImage *rle);
     
void g_FillRectNC(const TCanvas *canvas, int l, int t, int r, int b, int color);

void g_FillCircleNC(const TCanvas *canvas, int x, int y, int radius, int color);


/////////////////////////////////////////////////////////////////////////////
// Alpha blending functions (no-clipping version)

// Darken is RGBnew = RGBsrc / 2 + RGBdst / 2, i.e. blend(50, 50)
void g_DrawImageDarkenNC(const TCanvas *canvas, int x, int y, const TImage *image);

void g_FillRectDarkenNC(const TCanvas *canvas, int l, int t, int r, int b, int color);

// Blend is RGBnew = RGBsrc * sf/100 + RGBdst * df/100
//	sf		is source factor 0 ~ 100
//	df		is destination factor 0 ~ 100
void g_DrawImageBlendNC(const TCanvas *canvas, int x, int y, const TImage *image, int sf, int df);

void g_FillRectBlendNC(const TCanvas *canvas, int l, int t, int r, int b, int color, int sf, int df);

// Alpha is RGBnew = RGBsrc * a/255 + RGBdst * (255-a)/255, a is 0 ~ 255
//	alpha	is alpha values for mapping each pixels in image
void g_DrawImageAlphaNC(const TCanvas *canvas, int x, int y, const TImage *image, const UInt8 *alpha);

void g_DrawPixelAlphaNC(const TCanvas* canvas, int x, int y, int color, UInt8 alpha);

// bits		is the bits number of intensity, 8 bits means 256 level 
//		    which effect the opacity of AA line
// level	must = 2^bits
void g_SetLineAABitsLevel(int bits, int level);

/* Draw anti-aliased line */
void g_DrawLineAANC(const TCanvas* canvas, int x0, int y0, int x1, int y1, int color);

#ifdef __cplusplus
}
#endif

#endif	// __DRAW_NC_H__
